<!DOCTYPE html>
<%@page import="servlet.IConstants"%>
<%@page import="domain.User"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*, domain.Preference, java.util.Iterator;"%>


<html>
<head>
<meta charset="UTF-8">
<title>Vélo Paris</title>
<link rel="stylesheet" href="css/page.css">
<link rel="stylesheet" href="css/recherche.css">
<script type="text/javascript" src="javascript.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
	google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body onload="initializeC()">
	<header class="header">
		<h1>
			<a href="accueil.html"> <img src="images/velo.jpeg" alt="Image"
				class="imagehome">
			</a>
		</h1>
		<div id="menuhome">
			<ul>
				<li><a href="accueil.html">Accueil</a></li>
				<li><a href="recherche.html" id="current">Recherche d'un
						vélo</a></li>
				<li><a href="connexion.jsp">Connexion</a></li>
				<li><a href="contact.html">Contacts</a></li>
				<li><a href="Deconnexion">Déconnecter</a></li>
			</ul>
		</div>
	</header>

	<br />
	<br />
	<br />
	<br />
	<br />
	<br />

<jsp:include page="header_user.jsp"></jsp:include>
	<div id="containerR">
		<div id="rechercheC" align="center">
			<table id="tableRecherche">
				<tr>
					<td align="center">Départ:</td>
					<td><input id="selectAdresseDT" list="selectAdresseD">
						<datalist id="selectAdresseD">
							<%
								User user = (User) session.getAttribute(IConstants.user);
								if (user != null) {
									List<Preference> carnetAdd = new ArrayList<Preference>(user.getAddressBook());
									Collections.sort(carnetAdd, new Comparator<Preference>() {
										public int compare(Preference o1, Preference o2) {
											return o1.getAddress().compareToIgnoreCase(o2.getAddress());
										}
									});
									for (Preference pref : carnetAdd) {
							%>
							<option value="<%out.print(pref.getAddress());%>">
								<%
									out.print(pref.getAlias());
								%>
							</option>
							<%
								}
								}
							%>
						</datalist></td>
				</tr>
				<tr>
					<td>Destination:</td>
					<td><input id="selectAdresseAT" list="selectAdresseA">
						<datalist id="selectAdresseA">
							<%
								user = (User) session.getAttribute(IConstants.user);
								if (user != null) {
									List<Preference> carnetAdd = new ArrayList<Preference>(user.getAddressBook());
									Collections.sort(carnetAdd, new Comparator<Preference>() {
										public int compare(Preference o1, Preference o2) {
											return o1.getAddress().compareToIgnoreCase(o2.getAddress());
										}
									});
									for (Preference pref : carnetAdd) {
							%>
							<option value="<%out.print(pref.getAddress());%>">
								<%
									out.print(pref.getAlias());
								%>
							</option>
							<%
								}
								}
							%>
						</datalist></td>
				</tr>
			</table>
			<input id="btnRechercheU" type="button" value="Recherche"
				onclick='stationFormGUETTO("oui")'> <br />
			<br/>
			<div id="parcours"></div>
			<div id="distEtDurat1"></div>
			<div id="distEtDurat2"></div>
			<div id="distEtDurat3"></div>
			<div id="map-canvasC"></div>
		</div>
		<div id="carnet">
			<div id="carnetAdresse">
				<p />
				Carnet Adresse
				<p />
				<input id="buttonAjourRecherche" type="button"
					onclick="popupRajouterAdresse()" value="Ajouter Adresse" />
				<ul>
					<%
						user = (User) session.getAttribute(IConstants.user);
						if (user != null) {
							List<Preference> carnetAdd = new ArrayList<Preference>(user.getAddressBook());
							Collections.sort(carnetAdd, new Comparator<Preference>() {
								public int compare(Preference o1, Preference o2) {
									return o1.getAlias().compareToIgnoreCase(o2.getAlias());
								}
							});
							for (Preference pref : carnetAdd) {
								out.print("<li style='list-style-type: none'>");
								out.print(pref.getAlias());
								out.println("</li>");
							}
						}
					%>
				</ul>

			</div>
			<br /> <br />

		</div>
		<br />
	</div>
</body>
</html>

